﻿Imports Microsoft.Win32
Imports SIREntities
Module ModMain
  Public Const gc_sRegClavePrincipal As String = "Software\SIR" 'Global ruta principal en el registro de windows
  Public Const gc_sRegValorConnectStr As String = "ConnectString" 'Valor con contiene la connect_string a la bd
  Public g_sConnectString As String ' Global que contendra la cadena de conexion a la bd

  Public g_sModulo As String = My.Application.Info.Title  'Global Title Programa
  Public oUsuario As New clsUsuarioBE

  Public Function GetValueRegister(ByVal psName As String, ByVal psNameValue As String) As String 'Retorna el valor de registro
    Try
      Dim key As RegistryKey = Registry.LocalMachine.OpenSubKey(psName, False)

      If key Is Nothing Then Return ""

      Return key.GetValue(psNameValue)
    Catch ex As Exception
      Return ""
    End Try
  End Function

  Public Sub CargarValoresGlobalesRegistro()
    Try
      g_sConnectString = GetValueRegister(gc_sRegClavePrincipal, gc_sRegValorConnectStr)

    Catch ex As Exception
      'MANEJO DE ERRORES
      'MessageBox.Show(ex.Message, g_sModulo, MessageBoxButtons.OK, MessageBoxIcon.Error)
      'Diagnostics.EventLog.WriteEntry(g_sModulo, ex.Message, EventLogEntryType.Error, m_eventID, Nothing)
    End Try
  End Sub

End Module
